﻿using DeviceMonitor.Dao;
using DeviceMonitor.Model;
using DeviceMonitor.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DeviceMonitor.Windows
{
    /// <summary>
    /// BillItemsWindow.xaml 的交互逻辑
    /// </summary>
    public partial class BillItemsWindow : Window
    {
        BillItemsViewModel viewModel;
        string billId;
        public BillItemsWindow()
        {
            InitializeComponent();
            viewModel = new BillItemsViewModel();
            this.DataContext = viewModel;

            this.Loaded += Window_loaded;
        }

        private void Window_loaded(object sender, RoutedEventArgs e)
        {
            loadData();
        }
        private void loadData()
        {
            Hashtable paraMap = new Hashtable();
            paraMap.Add("billId", billId);

            ArrayList list = (ArrayList)SqlMapDao.instance().QueryForList("selectBillItems", paraMap);
            viewModel.list.Clear();
            foreach (BillItemModel item in list)
            {
                viewModel.list.Add(item);
            }
        }
        public void setBillID(string billId)
        {
            this.billId = billId;
        }


    }
}
